home *** CD-ROM | disk | FTP | other *** search
- rem
- rem $Header: examp1.sql 7020100.1 94/09/28 16:39:56 cli Generic<base> $
- rem
- Rem Copyright (c) 1991 by Oracle Corporation
- Rem NAME
- Rem examp1.sql - <one-line expansion of the name>
- Rem DESCRIPTION
- Rem <short description of component this file declares/defines>
- Rem RETURNS
- Rem
- Rem NOTES
- Rem <other useful comments, qualifications, etc.>
- Rem MODIFIED (MM/DD/YY)
- Rem rvasired 05/12/92 - Creation
- /*
- ** This block processes an order for tennis rackets. It decrements
- ** the quantity of rackets on hand only if there is at least one
- ** racket left in stock.
- **
- ** Copyright (c) 1989,1992 by Oracle Corporation
- */
-
- DECLARE
- qty_on_hand NUMBER(5);
- BEGIN
- SELECT quantity INTO qty_on_hand FROM inventory
- WHERE product = 'TENNIS RACKET'
- FOR UPDATE OF quantity;
-
- IF qty_on_hand > 0 THEN -- check quantity
- UPDATE inventory SET quantity = quantity - 1
- WHERE product = 'TENNIS RACKET';
- INSERT INTO purchase_record
- VALUES ('Tennis racket purchased', SYSDATE);
- ELSE
- INSERT INTO purchase_record
- VALUES ('Out of tennis rackets', SYSDATE);
- END IF;
-
- COMMIT;
- END;
- /
-